<template>
	<view class="container saleorder">
		<myhead :title="mytitle"></myhead>
		<view class="top">
			<view class="search">
				<icon type="search" class="searchicon"></icon>
				<input class="searchinput" placeholder="请输入内容"/>
			</view>
			<view class="condition">
				<view class="timerpicker">
					<uni-datetime-picker
						v-model="range"
						type="daterange"
						rangeSeparator="至"
					/>
				</view> 
				<view class="orderpicker">
					<picker @change="bindPickerChange" :range="array" class="pickerbox">	
						<label>类型：</label>
						<label style="color: #333333;">{{array[index]}}</label>
					</picker>
				</view>
			</view>
		</view>
		<view class="detailbill">
			<scroll-view scroll-y="true" class="myscroll">
				<view class="item" v-for="(item,index) in orderArray" :key = "index" @tap = "todetail(item.id)">
					<view class="top">
						<text>单号：{{item.title}}</text>
						<view class="money">
							<text>￥{{item.money}}</text>
							<text 
							class="state"
							:style="{backgroundColor:(item.state == '0' ? 'green' : item.state == '1' ? 'red' : 'gray')}"
							v-text="item.state == '0' ? '已结清' : item.state == '1' ? '已赊欠' : '已作废'">
							</text>
						</view>
					</view>
					<view class="middle">
						<view class="each saletime">
							销售时间：{{item.saletime}}
						</view>
						<view class="each ordertime">
							开单时间：{{item.ordertime}}
						</view>
					</view>
					<view class="bottom">
						<view class="products">
							{{item.product.join(',')}}
						</view>
					</view>
				</view>
			</scroll-view>
		</view>
	</view>
</template>

<script>
	import myhead from "../../components/header/header.vue"
	export default {
		data() {
			return {
				mytitle:'销售订单管理',
				range: [],
				array:['全部','赊欠','结清','退款'],
				index:0,
				orderArray:[
					{
						id:'12312313',//标识记号
						title:'00001/临时客户',
						money:'4530',
						state:'0',//0已结清，1赊欠，2作废
						saletime:'2021-10-10',//销售日期
						ordertime:'2021-10-10 11:29:30',//开单时间
						product:['八爪鱼','黄螺']
					},
					{
						id:'12312313',//标识记号
						title:'00001/临时客户',
						money:'4530',
						state:'1',//0已结清，1赊欠，2作废
						saletime:'2021-10-10',//销售日期
						ordertime:'2021-10-10 11:29:30',//开单时间
						product:['八爪鱼','黄螺']
					},
					{
						id:'12312313',//标识记号
						title:'00001/临时客户',
						money:'4530',
						state:'2',//0已结清，1赊欠，2作废
						saletime:'2021-10-10',//销售日期
						ordertime:'2021-10-10 11:29:30',//开单时间
						product:['八爪鱼','黄螺']
					},
					{
						id:'12312313',//标识记号
						title:'00001/临时客户',
						money:'4530',
						state:'1',//0已结清，1赊欠，2作废
						saletime:'2021-10-10',//销售日期
						ordertime:'2021-10-10 11:29:30',//开单时间
						product:['八爪鱼','黄螺']
					},
					{
						id:'12312313',//标识记号
						title:'00001/临时客户',
						money:'4530',
						state:'2',//0已结清，1赊欠，2作废
						saletime:'2021-10-10',//销售日期
						ordertime:'2021-10-10 11:29:30',//开单时间
						product:['八爪鱼','黄螺']
					}
				]
			}
		},
		methods: {
			bindPickerChange(e){
				this.index = e.target.value
			},
			todetail(id){
				uni.navigateTo({
				    url: `/pages/orderdetail/orderdetail?id=${id}`
				});
			}
		},
		watch: {
			range(newval) {//监听日期选择范围
				 console.log("范围选:", this.range);
			}
		},
		components:{
			myhead,
		}
	}
</script>

<style scoped lang="scss">
/deep/.uni-date__x-input{
		padding: 0 10rpx;
		height: 50rpx !important;
		width: 100%;
		line-height: 50rpx;
		font-size: 20rpx;
	}
/deep/.uni-date__icon-clear{
	display: none !important;
}
.saleorder{
	color: black;
	display: flex;
	flex-direction: column;
	.top{
		padding-left: 12rpx;
		padding-right: 12rpx;
		.condition{
			margin-top: 20rpx;
			display: flex;
			align-items: center;
			.timerpicker{
				width: 60%;
			}
			.orderpicker{
				width: 20%;
				margin-left: 20rpx;	
				.pickerbox{
					text-align: center;
					border: 2rpx solid #dcdfe6;
					border-radius: 8rpx;	
					height: 25px !important;
					line-height: 25px;
					font-size: 10px;
					color: grey;
				}
			}
		}
	}
	.detailbill{
		flex: 1;
		margin-top: 20rpx;
		background-color: #EEEEEE;
		padding: 12rpx;
		overflow: hidden;
		.myscroll{
			height: 100%;
			overflow: hidden;
		}
		.item{
			background-color: #FFFFFF;
			margin-bottom: 20rpx;
			border-radius: 16rpx;
			padding: 20rpx;
			box-sizing: border-box;
			.top{
				display: flex;
				align-items: center;
				justify-content: space-between;
				padding: 10rpx 0;
				font-size: 32rpx;
				font-weight: bold;
				.state{
					margin-left: 10rpx;
					color: #FFFFFF;
					font-size: 24rpx;
					padding: 4rpx 8rpx;
					font-weight: normal;
					
				}
			}
			.middle{
				font-size: 24rpx;
				color: grey;
				padding: 10rpx 0;
				border-bottom: 2rpx solid #dcdfe6;
				.each{
					line-height: 40rpx;
				}
			}
			.bottom{
				padding: 20rpx 0;
				font-size: 24rpx;
			}
		}
	}
}
</style>
